package MOLE.Pay;

import MOLE.*;

/** 
 Order ��ժҪ˵����
*/
public class Order extends App.Every
{

	public long Oid;
	public java.math.BigDecimal money = new java.math.BigDecimal(0);
	public String paytype = "alipay";
	public int uid = MOLE.GetValue.GetCookieInt("hy_num");
	public int status = 0;
	public String statusStr = "";
	public String Owner = "";
	private String StatusNotExist = "��ֵʧ�ܣ�����ת����ɣ���δ�ڱ�ϵͳ�ҵ���ֵ�ʺţ�������ϵͳ����Ա��ϵ!";
	private String StatusCharged = "�Ѿ���ֵ�����!!";
	private String StatusOk = "��ֵ�ɹ�!!";
	private String StatusSyserr = "ת�ʳɹ�������վϵͳ�����³�ֵʧ��!���׺�: ";
	public Order(Object oid)
	{
		//
		// TODO: �ڴ˴���ӹ��캯���߼�
		//
		Oid = (Long)oid;
		StatusSyserr += String.valueOf(Oid);

		String s = "exec Order_list " + String.valueOf(Oid);
		DataTable d = MOLE.SQL.GetDataTable(s);
		if (d.Rows.size() != 0)
		{
			Owner = d.Rows[0]["uname"].toString().trim();
			money = (java.math.BigDecimal)(d.Rows[0]["money"].toString());
		}


	}

	public Order()
	{
	}

	public final boolean IsSubmit()
	{
		String s = "select * from [order] where 1=1 and status=1 and oid=" + String.valueOf(Oid);
		DataTable d = MOLE.SQL.GetDataTable(s);
		if (d.Rows.size() == 0)
		{
			return false;
		}
		else
		{
			return true;
		}

	}


	public final void Add()
	{

	//	string s=" exec Order_Add   oid,uid,money,paytype";
		MOLE.SQLOS so = new MOLE.SQLOS(" Order_Add");
		so.RS(Oid);
		so.RS(uid);
		 so.RS(money);
		so.RS(paytype);
		so.ExecStoreProcess();
		//exec Order_Add  2004,861109,1,'cncard'
		//MOLE.SQL.ExecuteSql(s);


	}


	public final void ShsyeOrder()
	{

		String sql = "exec Account_ChargeByOrder  " + String.valueOf(Oid).trim();
		MOLE.SQL.ExecuteSql(sql);


	}

	public final String Exec()
	{
		String sql = "exec Account_ChargeByOrder  " + String.valueOf(Oid).trim();
		String r = "";
		try
		{
			DataTable d = MOLE.SQL.GetDataTable(sql);
			r = d.Rows[0]["result"].toString();
			if (r.equals("ok"))
			{
				status = 0;
				statusStr = StatusOk;
			}
			else if (r.equals("notexist"))
			{
				status = 1;
				statusStr = StatusNotExist;
			}
			else if (r.equals("charged"))
			{
				status = 2;
				statusStr = StatusCharged;
			}
			else
			{
				status = 3;
				statusStr = " get order result exction ";
			}
		}
		catch (RuntimeException ee)
		{

			this.Log(" order.exe err " + ee.toString());
			status = 4;
			statusStr = StatusSyserr;
		}
		 return "";

	}

	public static boolean IsExist(long oid)
	{
		 String s = "select * from [order] where 1=1 and   oid=" + String.valueOf(oid);
		DataTable d = MOLE.SQL.GetDataTable(s);
		if (d.Rows.size() == 0)
		{
			return false;
		}
		else
		{
			return true;
		}
	}

}